package com.extweb4j.core.model;

import com.extweb4j.core.kit.ExtKit;
import com.jfinal.plugin.activerecord.Page;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ZhaoWeinan
 * @date 2018/12/20
 * @description
 */
public class ExtTenderSection extends CoreModel<ExtTenderSection> {

    private static final long serialVersionUID = 1L;

    public static ExtTenderSection dao = new ExtTenderSection();

    public Page<ExtTenderSection> pageSectionBy(int page, int limit, String keywords ,int tenderId) {

        String select = "SELECT id,tenderId,SectionName,FileNo,PurchaseDept,Deposit,cost ";

       /* String select  =  "SELECT u.id,u.user_id,u.user_pwd,u.user_name,u.user_email,"
                + "u.row_status,u.create_time,u.user_desc,d.dept_name,d.id AS dept_id,d.dept_desc ";*/

        StringBuffer form = new StringBuffer(" FROM Cm_TenderSection ");
        form.append(" WHERE 1=1 AND tenderId =  ? ");
        List<Object> paras = new ArrayList<Object>();
        paras.add(tenderId);

        if (StringUtils.isNotBlank(keywords)) {
            keywords = ExtKit.sqlFilterValidate(keywords);
            form.append(" AND (SectionName LIKE '%" + keywords + "%'");
        }
        form.append(" ORDER BY id ASC");
        return super.paginate(page, limit, select, form.toString(), paras.toArray());
    }



}
